package nc.ui.arap.perfbal.action;

import nc.ui.arap.view.ViewContext;
import nc.ui.pub.beans.UIRefPane;
import nc.ui.pub.bill.BillCellEditor;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillEditListener;
import nc.vo.arap.perfbal.QryObjFieldVO;

public class QryObjFieldEditListener implements BillEditListener {
	
	private ViewContext<QryObjFieldVO> context;

	public QryObjFieldEditListener(ViewContext<QryObjFieldVO> context) {
		this.context = context;
	}

	public void afterEdit(BillEditEvent e) {
		if ("billfield".equals(e.getKey())) {
			UIRefPane ref = (UIRefPane) ((BillCellEditor) e.getSource()).getComponent();
			context.getBatchTabelModel().getSelectData().setObjname((String) ref.getRefValue("name"));
			context.getBatchTabelModel().getSelectData().setBillfield((String) ref.getRefValue("code"));
			context.getBatchTabelModel().getSelectData().setRefid((String) ref.getRefValue("refid"));
			context.getBatchTabelModel().getSelectData().setRefname((String) ref.getRefValue("refname"));
			context.synchronizeModel(context.getListPanel().getHeadTable().getSelectedRow());
		}
		
	}

	public void bodyRowChange(BillEditEvent e) {
		context.getBatchTabelModel().setSelectedIndex(e.getRow());
	}

}
